Getting started
Chronicle's pull oracles offer the absolute freshest pricing information on-demand. We provide an SDK for simple integrations. Authentication is handled via tokens based on the Ethereum Signed Messages protocol.
Your public signing key must be allow-listed on our servers before you can generate tokens.
Generating authentication tokens on the server:
import { signAuthToken } from '@chronicleprotocol/pull-oracle';
const { token, message } = signAuthToken({
// private key is 0x prefixed 32 byte hex string
privateKey: "0xabc..."
})
We highly recommend following best practices for private key generation and storage. Use a unique private key for creating auth tokens. DO NOT re-use this private key for any other purpose!
Once the auth token is generated on the server, pass it to the client and register it with the authenticate
method of the pull-oracle
module for automatic inclusion in future requests.
Authenticating a user session on the client and fetching prices:
import { authenticate, getLatestPrices } from '@chronicleprotocol/pull-oracle';
// token is received from the server
// `authenticate` caches the token in memory so it only needs to be called once per session
authenticate(token);
const prices = await getLatestPrices([
{ wat: "MKR/USD" },
{ wat: "ETH/USD" }
]);